// sysModelBelong.js
const Base = require('../base.js');
// https://testjoylearning.bmw.com.cn:8080/sys/storeApprove/list?pageNo=1&pageSize=10
module.exports = function(sequelize, DataTypes) {
    function getAttributes(sequelize, DataTypes) {
        const attributes = {
            modelBelongId: {
                field: "model_belong_id",
                type: DataTypes.BIGINT(20),
                primaryKey: true,
                comment: "引用关系ID"
            },
            modelId: {
                field: "model_id",
                type: DataTypes.BIGINT(20),
                primaryKey: false,
                comment: "模型ID"
            },
            refAsName: {
                field: "ref_as_name",
                type: DataTypes.STRING(50),
                allowNull: false,
                comment: "子表名称"
               
            },
            tarModelId: {
                field: "tar_model_id",
                type: DataTypes.BIGINT(11),
                allowNull: false,
                comment: "子表类型ID"
               
            },
            tarModelCode: {
                field: "tar_model_code",
                type: DataTypes.STRING(50),
                allowNull: true,
                comment: "子表模型编码",
                
            },
            className: {
                field: "class_name",
                type: DataTypes.STRING(500),
                allowNull: true,
                comment: "对象的类型",
                
            },
            fKey: {
                field: "f_key",
                type: DataTypes.STRING(50),
                allowNull: true,
                comment: "外键名称",
                
            },
            tarKey: {
                field: "tar_key",
                type: DataTypes.STRING(50),
                allowNull: false,
                comment: "目标表键名称",
            },
            refName: {
                field: "ref_name",
                type: DataTypes.STRING(50),
                allowNull: true,
                comment: "子表的被填充属性名称",
            },
            refStr: {
                field: "ref_str",
                type: DataTypes.STRING(200),
                allowNull: true,
                comment: "附加字符串",
            },
            ...Base.getAttr(sequelize, DataTypes)
            
            
        };
        return attributes;
    };
    const sysModelBelong = sequelize.define('sysModelBelong', getAttributes(sequelize, DataTypes), {
        freezeTableName: true,
        tableName: "sys_model_belong",
        timestamps: false
    });
    
    // sysModelBelong.getHasMany = function(){
    //     return ["sysModelBelongAttrs"];
    // };
    Base.extendModel(sysModelBelong, getAttributes(sequelize, DataTypes));
    return sysModelBelong;
};